package org.codetranslators.compiler.abstractassembly;

import org.codetranslators.common.Label;
import org.codetranslators.common.Temp;

public class AssemName extends AssemExp
{
	private Label label;
	  
	public AssemName(Label l)
	{
		label = l;
	}
	
	public AssemExpList children()
	{
		return null;
	}
	
	public Label getLabel()
	{
		return label;
	}
	
	public AssemType translateToCJump(Label labelTrue, Label labelFalse)
	{
		
		return null;   // This should never happen
	}
	
	public AssemExp build(AssemExpList list)
	{
		return this;
	}
	
	/**
	* This function will coerce this binary operator expression into an int type,
	* by creating a temporary holding an int value
	*/
	public AssemType translateToIntType()
	{
		//return null; // This should never happen
		Temp destTemp = new Temp();
		AssemTemp assemTemp = new AssemTemp(destTemp);
		AssemMove assemMove = new AssemMove(assemTemp, this);
		return new AssemSeqExp(assemMove, assemTemp);
	}
		
	public int getType()
	{
		return INT_TYPE; // It does not matter
	}
	
	public String getDescription()
	{
		return "Name (" + label.toString() + ")";
	}
	
	public AssemSeqExp canonize()
	{
		return new AssemSeqExp(null, this);	
	}
	
	public int getExpType()
	{
		return AssemExp.NAME;
	}
}
